home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.04 Apr 95 / TreeAppƒ / PackedWindowƒ / CPPPackedTreeWindow.cp next >
Encoding:
Text File  |  1996-04-04  |  2.8 KB  |  108 lines  |  [TEXT/KAHL]

  1. /***************************************************** IMPLEMENTATION
  2.     DATE:    11/12/93
  3.  
  4.     CLASS:  CPPPackedTreeWindow
  5.     
  6.     SUPERCLASS: CPPTreeWindow
  7.     
  8.         This C++ class manages a window which has a packed visual tree
  9.     
  10. ********************************************************************/
  11.  
  12. #include "CPPPackedTreeWindow.h"
  13. #include <Commands.h>
  14. #include <MathTools.h>
  15. #include <CPPDRequest.h>
  16. #include "MyCommands.h"
  17. #include "CPPString.h"
  18. #include <CPPTreeArea.h>
  19. #include <CPPVisualTree.h>
  20. #include <CPPPackedTreeNode.h>
  21.  
  22. /*-----------------------------------------------------------------*/
  23. /*------------------------ PUBLIC METHODS -------------------------*/
  24. /*-----------------------------------------------------------------*/
  25.  
  26.     CPPPackedTreeWindow::CPPPackedTreeWindow (CPPWindowManager *theManager, int ResID) :
  27.                 CPPTreeWindow (theManager, ResID)
  28.     {    
  29.  
  30.     }
  31.                          
  32. /*-----------------------------------------------------------------*/
  33.  
  34.     CPPPackedTreeWindow::~CPPPackedTreeWindow (void)
  35.     {
  36.  
  37.     }
  38.  
  39. /*-----------------------------------------------------------------*/
  40.  
  41.     Boolean    CPPPackedTreeWindow::Member (char *className)
  42.     {
  43.         if (strcmp(className, CPPPackedTreeWindow::ClassName()) == 0)
  44.           return TRUE;
  45.         else
  46.           return CPPTreeWindow::Member(className);
  47.     }
  48.  
  49. /*-----------------------------------------------------------------*/
  50.  
  51.     char    *CPPPackedTreeWindow::ClassName (void)
  52.     {
  53.         return "CPPPackedTreeWindow";
  54.     }
  55.  
  56. /*-----------------------------------------------------------------*/
  57.  
  58.     Boolean    CPPPackedTreeWindow::DoCommand (short commandID)
  59.     /* the default method sends the command to the target of the */
  60.     /* window. */
  61.     /* SUBCLASS SHOULD OVERRIDE */
  62.     {
  63.         StringPtr    Reply = NULL;
  64.         long        TLint = 0;
  65.         CPPPackedTreeNode    *OperateOn = NULL,
  66.                             *TempNode = NULL;
  67.         CPPString    *STemp = NULL;
  68.         Boolean        result = TRUE;
  69.                 
  70.         switch (commandID) {
  71.         
  72. // kTreeMenu
  73.             case kCmdAdd        :
  74.                 if (this->theTreeArea->lastClicked)
  75.                   {
  76.                     OperateOn = (CPPPackedTreeNode *)this->theTreeArea->lastClicked;
  77.                     if (DoRequest ("\pEnter Child's name", "\pChild", &Reply))
  78.                       {
  79.                           STemp = new CPPString (Reply, TRUE);
  80.                           TempNode = new CPPPackedTreeNode (STemp, (CPPTree *)this->theTreeArea, 
  81.                                                           TRUE, FALSE);
  82.                         OperateOn->AddNode (TempNode);
  83.                       }
  84.                   }
  85.                 break;
  86.             
  87.             case kCmdInsert        :
  88.                 if (this->theTreeArea->lastClicked)
  89.                   {
  90.                     OperateOn = (CPPPackedTreeNode *)this->theTreeArea->lastClicked;
  91.                     if (DoRequest ("\pEnter new Parent's name", "\pParent", &Reply))
  92.                       {
  93.                           STemp = new CPPString (Reply, TRUE);
  94.                           TempNode = new CPPPackedTreeNode (STemp, (CPPTree *)this->theTreeArea, 
  95.                                                           TRUE, FALSE);
  96.                         OperateOn->InsertParent (TempNode);
  97.                       }
  98.                   }
  99.                 break;
  100.  
  101.             default :
  102.                 return CPPTreeWindow::DoCommand(commandID);
  103.                 break;    
  104.         }
  105.         
  106.         return result;
  107.     }
  108.